package com.arm.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.arm.common.utils.StringUtils;
import com.arm.system.domain.ArmArmedinfo;
import com.arm.system.domain.vo.ArmArmedinfoVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.arm.common.annotation.Log;
import com.arm.common.core.controller.BaseController;
import com.arm.common.core.domain.AjaxResult;
import com.arm.common.enums.BusinessType;
import com.arm.system.service.IArmArmedinfoService;
import com.arm.common.utils.poi.ExcelUtil;
import com.arm.common.core.page.TableDataInfo;

/**
 * 装备记录Controller
 * 
 * @author arm
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/system/armedinfo")
public class ArmArmedinfoController extends BaseController
{
    @Autowired
    private IArmArmedinfoService armArmedinfoService;

    /**
     * 查询装备记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:armedinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArmArmedinfo armArmedinfo)
    {
        startPage();
        List<ArmArmedinfo> list = armArmedinfoService.selectArmArmedinfoList(armArmedinfo);
        return getDataTable(list);
    }


    /**
     * 查询装备记录列表
     */
    @GetMapping("/listVo")
    public TableDataInfo listVo(ArmArmedinfo armArmedinfo)
    {
        startPage();
        List<ArmArmedinfoVo> list = armArmedinfoService.selectArmArmedinfoVoList(armArmedinfo);
        return getDataTable(list);
    }

    /**
     * 导出装备记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:armedinfo:export')")
    @Log(title = "装备记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArmArmedinfo armArmedinfo)
    {
        List<ArmArmedinfo> list = armArmedinfoService.selectArmArmedinfoList(armArmedinfo);
        ExcelUtil<ArmArmedinfo> util = new ExcelUtil<ArmArmedinfo>(ArmArmedinfo.class);
        util.exportExcel(response, list, "装备记录数据");
    }

    /**
     * 获取装备记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:armedinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(armArmedinfoService.selectArmArmedinfoById(id));
    }

    /**
     * 新增装备记录
     */
    @PreAuthorize("@ss.hasPermi('system:armedinfo:add')")
    @Log(title = "装备记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArmArmedinfo armArmedinfo)
    {
        if (StringUtils.isBlank(armArmedinfo.getType())){
            armArmedinfo.setType("equiping");
        }
        return toAjax(armArmedinfoService.insertArmArmedinfo(armArmedinfo));
    }

    /**
     * 修改装备记录
     */
    @PreAuthorize("@ss.hasPermi('system:armedinfo:edit')")
    @Log(title = "装备记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArmArmedinfo armArmedinfo)
    {
        return toAjax(armArmedinfoService.updateArmArmedinfo(armArmedinfo));
    }

    /**
     * 删除装备记录
     */
    @PreAuthorize("@ss.hasPermi('system:armedinfo:remove')")
    @Log(title = "装备记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(armArmedinfoService.deleteArmArmedinfoByIds(ids));
    }
}
